function rest=matelt(ax,bx,n)

%construct coefficient matrix A of equation
%a(x)u''+b(x)u'=f


h=1/n;
mesh=(0:1/n:1)';

ii=zeros(1,3*n-5);
jj=zeros(1,3*n-5);
kk=zeros(1,3*n-5);

%%diagnoal element
ii(1:n-1)=1:(n-1);
jj(1:n-1)=1:(n-1);
kk(1:n-1)=-2*ax(mesh(2:n))/h^2;

%%upper diagonal 
ii(n:2*n-3)=1:n-2;
jj(n:2*n-3)=2:n-1;
kk(n:2*n-3)=ax(mesh(2:n-1))/h^2+bx(mesh(2:n-1))/2/h;

%%lower diagonal
ii(2*n-2:3*n-5)=2:n-1;
jj(2*n-2:3*n-5)=1:n-2;
kk(2*n-2:3*n-5)=ax(mesh(3:n))/h^2-bx(mesh(3:n))/2/h;

rest=sparse(ii,jj,kk);





